<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 判断某一个数是否是质数？（质数：除了1和它本身以外不再有其他因数的自然数 )---质数大于一<br> -->
    <script>
        var num = prompt("请您输入一个数字");
        for (var i = 2; num >= i; i++) {
            if (num == i && num != 1) {
                document.write(num + "是质数");
                break;
            } else if (num == 1 || num % i == 0) {
                document.write(num + "不是质数");
                break;
            }
        }
    </script>
</body>

</html>